package com.kc.data.common.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.kc.data.common.domain.model.YsUser;
import com.kc.data.common.mapper.YsUserMapper;
import com.kc.data.common.service.YsUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName YsUserServiceImpl
 * @Description 用户信息service实现
 * @Author wangdongliang
 * @Date 2021/4/23 13:56
 */

@Service
public class YsUserServiceImpl implements YsUserService {
    @Resource
    private YsUserMapper ysUserMapper;
    @Override
    public YsUser getById(Integer userId) {
        return ysUserMapper.selectById(userId);
    }

    @Override
    public YsUser getByOpenid(String openId) {
        LambdaQueryWrapper<YsUser> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(YsUser::getOpenid,openId);
        return ysUserMapper.selectOne(wrapper);
    }

    @Override
    public YsUser getByMobile(String mobile) {
        LambdaQueryWrapper<YsUser> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(YsUser::getMobile,mobile);
        return ysUserMapper.selectOne(wrapper);
    }

    @Override
    public Integer add(YsUser ysUser) {
        ysUserMapper.insert(ysUser);
        return ysUser.getId();
    }

    @Override
    public Integer update(YsUser ysUser) {
        return ysUserMapper.updateById(ysUser);
    }

//    @Override
//    public List<YsTeacherStudentDTO> getStudentList(Integer teacherId, Integer classId) {
//        return ysUserMapper.getStudentList(teacherId,classId);
//    }
//
//    @Override
//    public YsTeacherStudentDTO getStudentId(Integer studentId) {
//        return ysUserMapper.getInfoById(studentId);
//    }
}
